import java.util.ArrayList;
import java.util.List;

class Product {
    private String name;
    private double price;

    public Product(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }
}


class ShoppingCart {
    private static final int number= 5;
    private List<Product> products;
    private int num;

    public ShoppingCart() {
        products = new ArrayList<>();
        num = 0;
    }


    public void addProduct(Product product) {
        if (num > number) {
            System.out.println("无法添加商品");
            return;
        }
        products.add(product);
        num++;
    }


    public void Cart() {
        System.out.println("购物车中的商品：");
        for (Product p : products) {
            System.out.println("名称：" + p.getName() + ", 价格：" + p.getPrice());
        }
    }


    public void remove(Product product) {
        if (products.remove(product)) {
            num--;
            System.out.println("已从购物车中删除 " + product.getName());
        } else {
            System.out.println("购物车中不存在该商品：" + product.getName());
        }
    }


    public double checkout() {
        double total = 0;
        for (Product p : products) {
            total += p.getPrice();
        }
        return total;
    }
}

public class shopping {
    public static void main(String[] args) {

        Product apple = new Product("苹果", 5.0);
        Product banana = new Product("香蕉", 3.0);
        Product coke = new Product("可乐", 2.5);

        ShoppingCart cart = new ShoppingCart();


        cart.addProduct(apple);
        cart.addProduct(banana);
        cart.addProduct(coke);


        cart.Cart();


        cart.remove(banana);


        cart.Cart();


        double cost = cart.checkout();
        System.out.println("结算：" + cost);
    }
}